﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace goMatic
{
    public partial class SHUTTER_CONTACT : System.Web.UI.UserControl
    {
        //public event EventHandler CheckedChanged;

        protected void Page_Load(object sender, EventArgs e)
        {
        }
        public SHUTTER_CONTACT()
        {
        }

        v_HMDeviceDetails vDetail;
        public v_HMDeviceDetails _Details
        {
            get { return vDetail; ; }
            set
            {
                if (value != null)
                {
                    vDetail = value;
                    dName.Text = vDetail.Name;
                    lDevice.Text = vDetail.Address;
                    if (vDetail.value != null)
                    {
                        _Contact = Convert.ToBoolean(int.Parse(vDetail.value));
                        TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
                        TimeSpan offset = tzi.GetUtcOffset(DateTime.Now);
                        lTime.Text = (value.C__createdAt.Value.LocalDateTime + offset).ToString("dd-MM HH:mm:ss");
                    }
                    else
                    {
                        Image2.ImageUrl = "~/Images/unknown.png";
                    }
                }
                else
                {
                    Image2.ImageUrl = "~/Images/unknown.png";
                }
            }
        }

        internal Boolean bContact;
        public Boolean _Contact
        {
            get
            {
                return bContact;
            }
            set
            {
                bContact = value;
                if (bContact)
                {
                    Image2.ImageUrl = "~/Images/fts_door_open_32.png";
                    lContact.Text = "offen";
                }
                else
                {
                    Image2.ImageUrl = "~/Images/fts_door_32.png";
                    lContact.Text = "zu";
                }
            }
        }
    }
}